var currPageIndex = 1;
var currPageSize = 20

$(function () {
    getRoleList();
    getUserList();
});

$('.search-btn').on('click', function () {
    getUserList();
});

function getUserList(callback) {
    if (typeof callback != 'function') {
        callback = function () {
        };
    }

    var data = $.getFormData();
    data.pageIndex = currPageIndex;
    data.pageSize = currPageSize;

    $.apiAjax({
        url: "/api/user/getUserList",
        data: data,
    }, function (res) {
        console.log(res);
        if (res.Code != 10000) {
            return false;
        }


    });
}

function getRoleList(callback) {
    if (typeof callback != 'function') {
        callback = function () {
        };
    }

    $.apiAjax({
        url: "/api/role/getRoleList",
        loading: false,
    }, function (res) {
        if (res.Code == 10000) {
            var list = res.Data;
            console.log(list);
            if (list.length) {
                var html = "";
                $.each(list, function () {
                    html += '<li><a href="javascript:;" data-value="' + this.id + '">' + this.roleName + '</a></li>';
                });
                $('[name=roleId]').parents('.cus-sel').find('.cus-sel-list ul').append(html);
                $('[name=roleId]').parents('.control-group').show();
            }
        }
    });
};